<!DOCTYPE html>
<html>
	<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>实习结束材料</title>
    <meta name="description" content="实习结束学生要提交的材料">
    <meta name="keywords" content="大学生实习证明,实习自我鉴定,实习报告总结,顶岗实习周记">
    <link href="{$Think.const.CSS_URL}bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="{$Think.const.CSS_URL}style.css">
    <script src="{$Think.const.JS_URL}jquery-1.12.3.min.js"></script>    
	<script src="{$Think.const.JS_URL}bootstrap.min.js"></script>
	<script src="{$Think.const.JS_URL}app.js"></script>
	<style>
		tr td{
		   text-align: center;
		   vertical-align: middle;
		}
	</style>
	<script>
		function urlDownLoad(content,fileName){
		        var aEle = document.createElement("a");// 创建a标签
		        // blob = new Blob([content]); 
		        aEle.download = fileName;// 设置下载文件的文件名
		        //aEle.href = URL.createObjectUrl(blob);
		        aEle.href = content;// content为后台返回的下载地址
		        aEle.click();// 设置点击事件
		
		}
	</script>
	</head>
	<body>
		<div class="container-fluid">
		   <div class="row">
			   <div class="col-md-12">
					   <ol class="breadcrumb">
					     <li style="font-size:1.5em;"><a href="#">实习材料分类</a></li>
					     <li class="active">实习结束需要学生提交哪些资料</li>
						 <a class="btn btn-default" href="#" role="button" onclick="$('#add').modal('show')">+添加材料分类</a>
						 
						 <a style="float:right;" class="btn btn-primary" href="{:url('shixi/grade_finish')}" role="button">实习材料管理</a>
					   </ol>	
				   
				<div class="alert alert-warning" role="alert" >
				<button type="button" onclick="gfadd()" class="btn btn-default" data-toggle="tooltip" data-placement="left" title="给学生实习规范性原始格式,学生做实习资料使用">实习格式文件上传</button>
				<span id="res">
					<script>var ex=0</script>
				{volist name="class" id="data" key="k"}
				    {if condition="($data.flag ==1)"}
					   <script>ex=1</script>
                       {if condition="($data['example']!='')"}
                       实习规格文件已上传<a href="{$Think.const.SITE_URL}uploads/{$data['example']}"><span class="glyphicon glyphicon-save" aria-hidden="true" ></span>查看</a>
                       {/if}
					{/if}
				{/volist}
				<script>
					if(ex!=1){
					document.write('实习规划文件未上传，<a href="#" onclick="gfadd()">快上传吧</a>')	
					}
					
				</script>
				</span>
				</div>
				
				
				   
				   <form id="class">
				   {empty name="class"}
					  暂无材料分类
				   {else /}
					<table class="table table-bordered">
						<tr>
						  <td >#ID</td>
						  <td >标题</td>
						  <td >要求</td>
						  <td >样表或案例下载</td>
						  <td >状态</td>
						  <td >时间</td>
						  <td >操作</td>
						</tr>
						{volist name="class" id="data" key="k"}
						 {if condition="($data.flag ==0)"}
						<tr>
						  <td >{$k}</td>
						  <td >{$data.title}</td>
						  <td style="width: 40%;">{$data.content}</td>
						  <td >
						    {if condition="($data.example =='')"} 
							无 <a href="#" onclick="up({$data.id})">上传</a>
						    {else /}
							<a href="{$Think.const.SITE_URL}uploads/{$data['example']}" target="_blank" ><span class="glyphicon glyphicon-save" aria-hidden="true" ></span>查看</a>
							<a href="#" onclick="up({$data.id})">更新</a>
						    {/if}
						  
						  
						  </td>
						  <td >
						  
						  {if condition="($data.status ==0)"}
						    正在使用
						  {else /}
                            停用
						  {/if}
						  
						  </td>

						  
						  <td >{$data.create_time|substr=0,10}</td>
						  <td >
							  <a style="margin-right:10px;" href="#" onclick="edit({$data.id})">修改</a> 
							   <a href="#" style="margin-right:10px;"  onclick="del({$data.id})">删除</a>
							   {if condition="($data.status ==0)"}
							     <a  href="#" onclick="change({$data.id},{$data.status})">停用</a> 
							   {else /}
							     <a  href="#" onclick="change({$data.id},{$data.status})">使用</a> 
							   {/if}
						  </td>
						</tr>
						{/if}
						{/volist}
					
					</table>
					{/empty}
                     </form>


		        </div>
		  </div>
		</div>
		
				
	<!--上传规范文件-->
	<div class="modal fade" tabindex="-1" role="dialog" id="gfadd">
	  <div class="modal-dialog" role="document" style="z-index: 11111;">
	    <div class="modal-content">
	      <div class="modal-header">
			  <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
			  
	        <h4 class="modal-title">上传规范文件</h4>
	      </div>
	      <div class="modal-body">
	         <form  enctype="multipart/form-data" method="post" id="gfform">
	         <input type="file" name="file" id="file1" accept=".rar,.zip"/ onchange="checkfile()"> <br> 
			 
	         <input type="button" value="上传" onclick="gfaddsave()" /> 
	         </form>   
	      </div>
	
	    </div><!-- /.modal-content -->
	  </div><!-- /.modal-dialog -->
	</div><!-- /.modal -->
	
	
	<script type="text/javascript">
	    var maxsize = 8*1024*1024;//8M 
	    var errMsg = "上传的附件文件不能超过8M！！！"; 
	    var tipMsg = "您的浏览器暂不支持计算上传文件的大小，确保上传文件不要超过8M，建议使用FireFox、Chrome浏览器。"; 
	    var browserCfg = {}; 
		var fileType=".zip .rar";
	    var ua = window.navigator.userAgent; 
	    if (ua.indexOf("MSIE")>=1){ 
	      browserCfg.ie = true; 
	    }else if(ua.indexOf("Firefox")>=1){ 
	      browserCfg.firefox = true; 
	    }else if(ua.indexOf("Chrome")>=1){ 
	      browserCfg.chrome = true; 
	    } 
		
	    function checkfile(){ 
	      try{ 
	        var obj_file = document.getElementById("file1"); 
			var index1=obj_file.value.lastIndexOf(".");
			var vType=obj_file.value.substring(index1+1,obj_file.length).toLowerCase();//后缀名
			if(fileType.indexOf(vType)<0){
			            obj_file.value="";
			            alert("文件附件格式不正确，请重新上传！");
			            return false;
			 }
	
	        if(obj_file.value==""){ 
	          alert("请先选择上传文件"); 
	          return; 
	        } 
	        var filesize = 0; 
	        if(browserCfg.firefox || browserCfg.chrome ){ 
	          filesize = obj_file.files[0].size; 
	        }else if(browserCfg.ie){ 
	          var obj_img = document.getElementById('tempimg'); 
	          obj_img.dynsrc=obj_file.value; 
	          filesize = obj_img.fileSize; 
	        }else{ 
	          alert(tipMsg); 
	        return; 
	        } 
	        if(filesize==-1){ 
	          alert(tipMsg); 
	          return; 
	        }else if(filesize>maxsize){ 
	          alert(errMsg); 
	          return; 
	        }
	      }catch(e){ 
	        alert(e); 
	      } 
	    } 
	  </script> 
	
	
	<script>		
		function gfadd(){
			$('#gfadd').modal('show')
		  }
			
			
		function gfaddsave(){
			var form = new FormData(document.getElementById("gfform"));
		   $.ajax({
		       type:"post",
		       url:"{:url('shixi/gfupload')}",
		       dataType:"text",
		       data:form,
			   processData : false, // 使数据不做处理
			   contentType : false, // 不要设置Content-Type请求头
	
		       success:function(data){  
		        alert(data); 
			     location.reload()
		       }
		       });     		
			}
		 
	</script>
			
	
		
		<!--添加-->
		<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" id="add">
		  <div class="modal-dialog modal-lg" role="document" style="z-index: 11111;">
		    <div class="modal-content">
		      <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
		        <h4 class="modal-title">添加实习材料分类</h4>
		      </div>
		      <div class="modal-body">	        				   
					<form class="form-horizontal" id="addform">
					  
					  <div class="form-group">
					      <label for="inputEmail3" class="col-sm-2 control-label">材料名称</label>
					      <div class="col-sm-10">
					        <input type="text" class="form-control" name="title" id="title" placeholder="尽量不要超过8个汉字，如实习报告">
					      </div>
					    </div>
										   
					   
					  <div class="form-group">
					      <label for="inputEmail3" class="col-sm-2 control-label">材料要求</label>
					      <div class="col-sm-10">
					        <textarea style="height:400px;width:700px;" class="form-control" name="content" id="content" placeholder="材料的规范要求"></textarea>
					      </div>
					    </div>
											  
					  <input type="hidden" name="xi" value={$xi}>
					  <center><button type="button" class="btn btn-primary" onclick="addclass()">发布</button></center>
					</form>	
																			  									  																			  
		      </div>
		    </div><!-- /.modal-content -->
		  </div><!-- /.modal-dialog -->
		</div><!-- /.modal -->
		
	<script>
		  	  
	function addclass(){
		var title=$("#title").val();
		if(title==""){
		  alert('名称不能为空');
		   return 
		}
	   $.ajax({
		   type:"post",
		   url:"{:url('shixi/grade_cailiaoAdd')}",
		   dataType:"text",
		   data:$('#addform').serialize(),
		   success:function(data){  
			alert(data); 
			location.reload(); 
		   }
		   });     		
	  }
	  
	  function del(id){
	    if(confirm('确定删除吗?')){
	     $.ajax({
	         type:"get",
	         url:"{:url('shixi/grade_cailiaoDel')}",
	         dataType:"text",
	         data:'id='+id,
	         success:function(data){  
	          alert(data);
	  		  location.reload();             
	         }
	         });     		
	  	}
	    }
		
		
	function change(id,status){
	   $.ajax({
	       type:"post",
	       url:"{:url('shixi/grade_cailiaoStatus')}",
	       dataType:"text",
	       data:{id:id,status:status},
	       success:function(data){  
	        alert(data);
			location.reload();             
	       }
	       });     		
	  }	
	  	
	</script>
		
	<!--编辑-->
		<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" id="edit">
		  <div class="modal-dialog modal-lg" role="document" style="z-index: 11111;">
		    <div class="modal-content">
		      <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
		        <h4 class="modal-title">编辑材料分类</h4>
		      </div>
		      <div class="modal-body">	        				   
					<form class="form-horizontal" id="editform">
                        <div class="form-group">
					      <label for="inputEmail3" class="col-sm-1 control-label">材料分类名称</label>
					      <div class="col-sm-11">
					        <input type="text" class="form-control" name="title" id="title1" placeholder="尽量不要超过8个汉字，如实习报告">
					      </div>
					     </div>
					  
					    <div class="form-group">
					      <label for="inputEmail3" class="col-sm-1 control-label">材料要求</label>
					      <div class="col-sm-11">
					        <textarea style="height:400px;width:800px;" class="form-control" name="content" id="content1" placeholder="材料的规范要求" style="width:100%;"></textarea>
					      </div>
					    </div>
					    <input type="hidden" name="id" id="id1">
					  <center><button type="button" class="btn btn-primary" onclick="save()">编辑</button></center>
					</form>	
																			  
									  
																			  
		      </div>
		    </div><!-- /.modal-content -->
		  </div><!-- /.modal-dialog -->
		</div><!-- /.modal -->
		
	<script>
		  	  
	function edit(id){
	   $("#id1").val(id);	
	   $.ajax({
		   type:"post",
		   url:"{:url('shixi/grade_getOneCailiao')}",
		   dataType:"json",
		   data:{id:id},
		   success:function(data){
			   data=eval("("+data+")")
			  $("#title1").val(data['title']);
			  $("#content1").val(data['content']);
			  
			 $('#edit').modal('show')
		   }
		   });     		
	  }
	  
	  function save(){
	    
	     $.ajax({
	         type:"post",
	         url:"{:url('shixi/grade_cailiaoSave')}",
	         dataType:"text",
	         data:$('#editform').serialize(),
	         success:function(data){  
	          alert(data);
	  		  location.reload();             
	         }
	         });     		
	  	}
	
	</script>
	
	<!--查看要求 -->
		<div class="modal fade " tabindex="-1" role="dialog" id="see1">
		  <div class="modal-dialog " role="document" style="z-index: 11111;">
		    <div class="modal-content">
		      <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
		        <h4 class="modal-title">查看要求</h4>
		      </div>
		      <div class="modal-body" id="seecont">	        				   																			  
									  
																			  
		      </div>
		    </div><!-- /.modal-content -->
		  </div><!-- /.modal-dialog -->
		</div><!-- /.modal -->
		
	   <script>
	   	  
	   	function see(id){
	
	   	   $.ajax({
	   	       type:"post",
	   	       url:"{:url('shixi/grade_getOneCailiao')}",
	   	       dataType:"json",
	   	       data:{id:id},
	   	       success:function(data){  
	   	        data=eval("("+data+")")
                $('#seecont').html(data['content'])
	   			} 
	   	       }); 
			$('#see1').modal('show')			   
	   		}  
	   </script>
	   		
	<!--上传-->
		<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" id="upload">
		  <div class="modal-dialog modal-lg" role="document" style="z-index: 11111;">
		    <div class="modal-content">
		      <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
		        <h4 class="modal-title">上传样表或案例文件</h4>
		      </div>
		      <div class="modal-body">	        				   
					<form class="form-horizontal" id="uploadform" name="uploadform">
					  
					  <div class="form-group">
					      <label for="inputEmail3" class="col-sm-2 control-label">样表或案例文件</label>
					      <div class="col-sm-10">
					        <input type="file" class="form-control" name="example" id="example" accept=".doc,.pdf,.docx" onchange="checkfile1()">只支持word,pdf文件，不要超过8MB
					      </div>
					    </div>	
					   <input type="hidden"  name="id"   id="id4">
 					  <center><button type="button" class="btn btn-primary" onclick="upsubmit()">上传</button></center>
					</form>	
																			  									  																			  
		      </div>
		    </div><!-- /.modal-content -->
		  </div><!-- /.modal-dialog -->
		</div><!-- /.modal -->
	
		
	
	<script type="text/javascript">
	    var maxsize1 = 8*1024*1024;//8M 
	    var errMsg = "上传的附件文件不能超过8M！！！"; 
	    var tipMsg = "您的浏览器暂不支持计算上传文件的大小，确保上传文件不要超过8M，建议使用FireFox、Chrome浏览器。"; 
	    var browserCfg = {}; 
		var fileType1=".doc.docx.pdf";
	    var ua = window.navigator.userAgent; 
	    if (ua.indexOf("MSIE")>=1){ 
	      browserCfg.ie = true; 
	    }else if(ua.indexOf("Firefox")>=1){ 
	      browserCfg.firefox = true; 
	    }else if(ua.indexOf("Chrome")>=1){ 
	      browserCfg.chrome = true; 
	    } 
	    function checkfile1(){ 
	      try{ 
	        var obj_file = document.getElementById("example"); 
			var index1=obj_file.value.lastIndexOf(".");
			var vType=obj_file.value.substring(index1+1,obj_file.length).toLowerCase();//后缀名
			if(fileType1.indexOf(vType)<0){
			            obj_file.value="";
			            alert("文件附件格式不正确，请重新上传！");
			            return false;
			 }

	        if(obj_file.value==""){ 
	          alert("请先选择上传文件"); 
	          return; 
	        } 
	        var filesize = 0; 
	        if(browserCfg.firefox || browserCfg.chrome ){ 
	          filesize = obj_file.files[0].size; 
	        }else if(browserCfg.ie){ 
	          var obj_img = document.getElementById('tempimg'); 
	          obj_img.dynsrc=obj_file.value; 
	          filesize = obj_img.fileSize; 
	        }else{ 
	          alert(tipMsg); 
	        return; 
	        } 
	        if(filesize==-1){ 
	          alert(tipMsg); 
	          return; 
	        }else if(filesize>maxsize1){ 
	          alert(errMsg); 
	          return; 
	        }
	      }catch(e){ 
	        alert(e); 
	      } 
	    } 
	  </script> 
	
	
		
	<script>
	function up(id){
	   $('#id4').val(id)
	   $('#upload').modal('show')
	}
	
			  
		  
	function upsubmit(){
		var form = new FormData(document.getElementById("uploadform"));
	   $.ajax({
	       type:"post",
	       url:"{:url('shixi/grade_cailiaoUploadExample')}",
	       dataType:"text",
	       data:form,
		   processData : false, // 使数据不做处理
		   contentType : false, // 不要设置Content-Type请求头
	    
	       success:function(data){  
	        alert(data); 
		     location.reload()
	       }
	       });     		
		}	  
		  
	</script>
	
	
	<!--ueditor使用开始 -->
	    <link href="/extend/umeditor1.2.3/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">   
	    <script type="text/javascript" charset="utf-8" src="/extend/umeditor1.2.3/umeditor.config.js"></script>
	    <script type="text/javascript" charset="utf-8" src="/extend/umeditor1.2.3/umeditor.min.js"></script>
	    <script type="text/javascript" src="/extend/umeditor1.2.3/lang/zh-cn/zh-cn.js"></script>
<!-- 	    <script type="text/javascript">var ue1 = UM.getEditor('content');</script> 
		<script type="text/javascript">var ue2 = UM.getEditor('content1');</script> -->
	</body>
</html>
